/*
 * @Description:
 * @Version: 2.0
 * @Autor: huangfu
 * @Date: 2020-09-14 16:21:23
 * @LastEditors: 大司马
 * @LastEditTime: 2021-01-18 11:45:44
 */
const path = require('path')
const packageName = require('./package').name
const webpack = require('webpack')
const resolve = dir => {
    return path.join(__dirname, dir)
}

module.exports = {
    publicPath: './',
    outputDir: 'dist',
    assetsDir: 'static',
    lintOnSave: false,
    chainWebpack: config => {
        config.plugin('provide').use(webpack.ProvidePlugin, [{
            'window.Quill': 'quill/dist/quill.js',
            'Quill': 'quill/dist/quill.js'
        }])
        config.resolve.alias
            .set('@', resolve('src'))
            .set('_c', resolve('src/components'))
    },
    productionSourceMap: false,
    devServer: {
        port: 9527,
        hot: true,
        open: true,
        headers: {
            'Access-Control-Allow-Origin': '*'
        }
        // // 跨域
        // proxy: {
        //     [process.env.VUE_APP_BASE_API]: {
        //         target: 'http://192.168.2.80:10000',
        //         ws: true,
        //         changeOrigin: true,
        //         pathRewrite: {
        //             [process.env.VUE_APP_BASE_API]: ''
        //         }
        //     }
        // }
    },
    configureWebpack: {
        performance: {
            hints: false
        },
        plugins: [
            new webpack.ProvidePlugin({
                'window.Quill': 'quill/dist/quill.js',
                'Quill': 'quill/dist/quill.js'
            })
        ],
        output: {
            filename: 'js/[name].js',
            library: `${packageName}-[name]`,
            libraryTarget: 'umd',
            jsonpFunction: `webpackJsonp_${packageName}`,
            globalObject: 'this'
        }
    }
}